package com.examples.ry.layouts;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * Normally, FillLayout is used to position a single child within a composite
 * that is typically a shell. It is rare that an application program needs to
 * fill a space evenly with multiple children.
 * 
 * 
 * There are two important differences to note between the FillLayout and
 * RowLayout versions of the code.
 * 
 * 1. Each control in the row layout is a
 * different size, whereas every control in the fill layout is the same size.
 *  
 * 2.When the shell is resized, the controls in the row layout are not resized, as
 * they would be using FillLayout. This makes RowLayout suitable when controls
 * need to retain their size.
 * 
 * @author ryada9
 * 
 */
public class FillLayout1 {

	public static void main(String[] args) {
		Display display = Display.getDefault();
		Shell shell = new Shell(display);
		FillLayout layout = new FillLayout(SWT.VERTICAL); // Default is
															// Horizontal
		layout.spacing = 10;
		layout.marginWidth = 50;
		layout.marginHeight = 50;
		shell.setLayout(layout);
		Button button = new Button(shell, SWT.PUSH);
		button.setText("Button");
		Button button2 = new Button(shell, SWT.PUSH);
		button2.setText("Button2");

		for (int i = 0; i < 12; i++) {
			Button button3 = new Button(shell, SWT.PUSH);
			button3.setText("B" + i);
		}
		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		//display.dispose();
	}

}
